package com.proxy.server.service;


import com.proxy.common.protocol.Message;
import com.proxy.server.task.TransferMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 用于 将用户信息转发给客户端
 */
public class TransferService {


    private ExecutorService executorService;

    /**
     * 将消息转发给客户端
     * @param message
     */
    public void toClient(Message message){
        executorService.submit(new TransferMessage(message));
    }

    /**
     * 启动转发服务
     */
    public void start(){
        int threads=Runtime.getRuntime().availableProcessors();
        executorService= Executors.newFixedThreadPool(threads);
    }

}
